package com.talkology.pilot.manager.controller;

import com.talkology.pilot.manager.model.TalkSalonMgtRest;
import com.talkology.pilot.manager.service.ITalkSalonMgtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/talkSalon")
public class TalkSalonMgtController {
    @Autowired
    private ITalkSalonMgtService service;

    @RequestMapping(value = "/info", method= RequestMethod.GET)
    @ResponseBody
    public TalkSalonMgtRest getInfo(@RequestParam(value = "className", required = true) String className) {
        return service.getInfo(className);
    }

    @RequestMapping(value = "/all", method= RequestMethod.GET)
    @ResponseBody
    public List<TalkSalonMgtRest> getAll(@RequestParam(value = "subject", required = false) String subject,
                                         @RequestParam(value = "teacher", required = false) String teacher) {
        return service.getAll(subject, teacher);
    }

    @RequestMapping(value = "/add", method= RequestMethod.PUT)
    @ResponseBody
    public void addTeacherInfo(@RequestBody TalkSalonMgtRest model) {
        service.addTalkSalon(model);
    }

    @RequestMapping(value = "/update", method= RequestMethod.PUT)
    @ResponseBody
    public void updateTeacherInfo(@RequestBody TalkSalonMgtRest model) {
        service.updateTalkSalon(model);
    }

    @RequestMapping(value = "/delete", method= RequestMethod.DELETE)
    @ResponseBody
    public void deleteTeacherInfo(@RequestParam(value = "index", required = false) String className) {
        service.deleteTalkSalon(className);
    }

}
